//
//  Auction_TitleSelectMore_View_WX.m
//  ZITHER
//
//  Created by weixin on 2019/6/1.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Auction_TitleSelectMore_View_WX.h"

@implementation Auction_TitleSelectMore_View_WX

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addToKeyWindow];
        [self.TitleSelectMoreBtnView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-15);
            make.top.equalTo(self).offset(NaviHeight);
            make.height.mas_equalTo(100);
            make.width.mas_equalTo(100);
        }];
    }
    return self;
}

-(void)show{
    [super show];
    [self addSubview:self.TitleSelectMoreBtnView];
}


-(BaseView *)TitleSelectMoreBtnView{
    if (!_TitleSelectMoreBtnView) {
        _TitleSelectMoreBtnView = [[BaseView alloc]init];
        [self addSubview:_TitleSelectMoreBtnView];
        _TitleSelectMoreBtnView.backgroundColor = [UIColor whiteColor];
        [_TitleSelectMoreBtnView setCornerRadiusWithRadius:4 isMasks:YES];
        NSArray *arrTitle = @[@"专场客服",@"分享"];
        NSArray *arrImg = @[@"nav_btn_descend",@"nav_btn_descend"];
        for (int i = 0 ; i<arrTitle.count; i++) {
            BaseBtn *btn = [BaseBtn initCustomBtnImageAndTitles:@[arrTitle[i]] images:@[arrImg[i]] color:@[HexColor(0x333333)]];
            if (i == 0) {
                [btn setTitleColor:baseColorTheme forState:UIControlStateNormal];
                [btn setTitleColor:baseColorTheme forState:UIControlStateSelected];
            }
            btn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14.f];
            btn.tag = 100+i;
            btn.imageView.contentMode = UIViewContentModeScaleAspectFit;
            [btn sizeToFit];
//            btn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, -20);
//            btn.imageEdgeInsets = UIEdgeInsetsMake(0, 30, 0, -70);
            [_TitleSelectMoreBtnView addSubview:btn];
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.equalTo(self.TitleSelectMoreBtnView.mas_centerX).offset(0);
                make.top.equalTo(self.TitleSelectMoreBtnView.mas_top).offset(10+i*35);
                make.height.mas_equalTo(20);
            }];
            if (i==0) {
                self.lastBtn = btn;
            }
            @weakify(self);
            [[btn addTag]subscribeNext:^(id  _Nullable x) {
                @strongify(self);
                [btn setTitleColor:baseColorTheme forState:UIControlStateNormal];
                [btn setTitleColor:baseColorTheme forState:UIControlStateSelected];
                [self.lastBtn setTitleColor:HexColor(0x333333) forState:UIControlStateNormal];
                [self.lastBtn setTitleColor:HexColor(0x333333) forState:UIControlStateSelected];
                self.lastBtn = btn;
                if (self.block) {
                    self.block(btn.tag,arrTitle,arrImg);
                }
                [self hide];
            }];
            
            
            
        }
        
    }
    return _TitleSelectMoreBtnView;
}

@end
